#ifndef Fl_Gl_ITK_h
#define Fl_Gl_ITK_h

#include <FL/Fl_Box.h>
#include <Fl/fl.h>
#include <iostream>
#include <FL/Fl_Gl_Window.h>
#include <FL/gl.h>
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageSliceConstIteratorWithIndex.h"
#include <itkImageRegionConstIterator.h>
#include <stdio.h>

namespace FPTK{

const int DimensionImageFL_GL_ITK = 3;



class Fl_Gl_ITK : public Fl_Gl_Window
{ 
public:

  Fl_Gl_ITK(int W, int H);
  Fl_Gl_ITK(int X, int Y, int W, int H, const char *l=0); 
  ~Fl_Gl_ITK();
  void draw();
  int LoadImage(char *filename);
  int handle(int event);
  void SetSlice(int nb);
  int GetDepth();
  int GetHeight();
  int GetWidth();
  int GetConstrastMax();
  void SetContrast(int value);
  void SetCalc(int value);
private:
    typedef  unsigned  short   PixelTypeImageFL_GL_ITK;
    typedef itk::Image< PixelTypeImageFL_GL_ITK,DimensionImageFL_GL_ITK>   ImageTypeImageFL_GL_ITK;
    typedef itk::ImageFileReader< ImageTypeImageFL_GL_ITK >  ReaderTypeImageFL_GL_ITK;
    typedef itk::ImageSliceConstIteratorWithIndex< ImageTypeImageFL_GL_ITK > SliceIteratorType;
    typedef itk::ImageRegionConstIterator< ImageTypeImageFL_GL_ITK > IteratorType;
    void Init();
    ReaderTypeImageFL_GL_ITK::Pointer ptreader;
    ImageTypeImageFL_GL_ITK::SizeType sizei;
    bool loaded,setcontrast,setdepth;
    int nbslice;
    GLubyte *imagei,*pos;
    int W,H,D;
    unsigned short max,contrastvalue,calc;
};

} //end namespace FPTK

#endif

